package com.hotelsystem.reservations.main;

import java.awt.Color;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenuBar;
import javax.swing.JPanel;

public class MainWindow {

	private final String welcomeMessage = "Welcome To The Hotel System!";
	private JPanel mainPanel;
	private JLabel welcomeMessageLabel;
	private MainMenuView mainMenu;
	private JFrame frame;

	public MainWindow() {
		BuildUI();
		//addListeners();
	}

	/*private void addListeners() {
		mainMenu.setCloseItemListener(new CloseItemActionListener());
	}

	private class CloseItemActionListener implements ActionListener {

		@Override
		public void actionPerformed(ActionEvent arg0) {
			System.exit(0);
		}
	}*/

	private void BuildUI() {
		mainPanel = new JPanel();
		FlowLayout mainLayout = new FlowLayout();
		mainPanel.setLayout(mainLayout);

		welcomeMessageLabel = createJLabelWelcomeMessage();

		mainPanel.add(welcomeMessageLabel);

		mainMenu = new MainMenuView();

		 JPanel main = getMainPanel();
		frame = new JFrame();
//		frame.setJMenuBar(mainMenu.getMainMenuBar());
		 frame.add(main);
		frame.setSize(700, 600);
		frame.setTitle("Hotel System");
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setVisible(true);
	}

	public void setJPanel(JPanel panel) {
		frame.getContentPane().removeAll();
		frame.getContentPane().add(panel);
		frame.invalidate();
		frame.validate();
	}

	public void setMenuBar(JMenuBar menuBar) {
		frame.setJMenuBar(menuBar);
	}

	public JFrame getMainFrame(){
		return frame;
	}
	
	private JLabel createJLabelWelcomeMessage() {
		JLabel result = new JLabel();
		result.setText(welcomeMessage);
		result.setFont(new Font("Serif", Font.BOLD, 16));
		result.setForeground(new Color(51, 0, 102));
		return result;
	}

	// public static void main(String[] args) {
	//
	// @SuppressWarnings("unused")
	// MainWindow mainWindow = new MainWindow();
	//
	// }

	public JPanel getMainPanel() {
		return mainPanel;
	}

	public void setMainPanel(JPanel mainPanel) {
		this.mainPanel = mainPanel;
	}

	public JLabel getWelcomeMessage() {
		return welcomeMessageLabel;
	}

	public void setWelcomeMessage(JLabel welcomeMessageLabel) {
		this.welcomeMessageLabel = welcomeMessageLabel;
	}

}
